home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-02-08 | 2.6 KB | 95 lines | [TEXT/KEEN] |
- # XRef_Full.T (or .A): from one or more source files, build a
- #cross-reference list of selected top-level terms.
- #NOT AN EXECUTABLE FILE: this file is used only as a "Template" by
- #$XRef_Full, which is the one to call for full cross-referencing.
- #The file "Skip for XRef" below holds a list of common terms to skip over.
- #In large cross-reference jobs it may be NECESSARY to skip the commonest
- #terms to avoid overflowing the list of references.
-
- BEGIN {
- skipfile = STDPATH "Drag_on Modules:hAWK programs:" "Skip for XRef"
- while (getline < skipfile > 0)
- {
- for ( k = 1; k <= NF; k++)
- skipList[$k] = 1; #Forces skipList[$k] to "exist".
- }
- close(skipfile)
- $0 = ""
- progressFile = STDPATH "$tempProgress"
- }
-
- FNR == 1 { z = split(FILENAME, names, ":")
- fName[++fIndex] = names[z]
- if (!progress("\nXReffing: " names[z]))
- { # concurrent mode, print progress to file
- print "XReffing:", names[z] > progressFile
- close(progressFile)
- }
- }
-
- #Strip down to words, look up term and record locations.
- #Only the file index is recorded - at end when printing, the index
- #is replaced by the proper file name.
- {#gsub(/'(.)*'/, "") - uncomment this to skip single quotes
- gsub(/[^A-Za-z0-9_]/, " ")
- for (i = 1; i <= NF; ++i)
- {
- #skip if in skipList
- if ($i in skipList)
- continue;
- type = lookup($i)
- ##MARK record
- #if (type == 1) #define
- # defines[$i] = defines[$i] "\t" fIndex "\t" FNR
- #else if (type == 2)#variable
- # vars[$i] = vars[$i] "\t" fIndex "\t" FNR
- #etc
- }
- }
-
- END {
- if (!progress("\nBuilding final list..."))
- { # concurrent mode, print progress to file
- print "Building final list..." > progressFile
- close(progressFile)
- }
- print "Cross-reference listing:"
- #build master array, for sorting all at once
- ##MARK linear
- #for (w in defines)
- # {
- # linear[++m] = w ": #define" defines[w]
- # delete defines[w]
- # }
- #for (w in vars)
- # {
- # linear[++m] = w ": variable" vars[w]
- # delete vars[w]
- # }
- #etc
- if (!progress("\nSorting final list..."))
- { # concurrent mode, print progress to file
- print "Sorting final list..." > progressFile
- close(progressFile)
- }
- sort(linear, ind, "d")
- if (!progress("\nPrinting final list to stdout..."))
- { # concurrent mode, print progress to file
- print "Printing final list to stdout..." > progressFile
- close(progressFile)
- }
- for (j = 1; j <= m; ++j)
- {
- r = split(linear[ind[j]], out, "\t")
- print out[1]
- for (t = 2; t <= r; ++t)
- {#print file name from array fName, print line number
- print "\t", fName[out[t]], out[++t]
- }
- print ""
- }
- if (m == 0)#nothing at all
- print "No top-level terms were found."
- }
-
-